<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Blog\LinkController as BlogLinkController;
use App\Http\Controllers\Admin\LinkController as AdminLinkController;
use App\Http\Controllers\Blog\CategoryController as BlogCategoryController;
use App\Http\Controllers\Blog\PostController as BlogPostController;
use App\Http\Controllers\Blog\TagController as BlogTagController;
use App\Http\Controllers\Blog\CommentController as BlogCommentController;
use App\Http\Controllers\Admin\CategoryController as AdminCategoryController;
use App\Http\Controllers\Admin\ImageController as AdminImageController;
use App\Http\Controllers\Admin\ConfigController as AdminConfigController;
use App\Http\Controllers\Admin\PostController as AdminPostController;
use App\Http\Controllers\Admin\TagController as AdminTagController;
use App\Http\Controllers\Admin\CommentController as AdminCommentController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// blog link rest api
Route::prefix("link")->group(function () {
    Route::get("/", [BlogLinkController::class, "list_sort"]);
    Route::post("/", [BlogLinkController::class, "save"]);
});

// blog category rest api
Route::prefix("category")->group(function () {
    Route::get("/", [BlogCategoryController::class, "list"]);
});

// blog post rest api
Route::prefix("post")->group(function () {
    Route::get("/", [BlogPostController::class, "listByPage"]);
    Route::get("/{id}", [BlogPostController::class, "findById"]);
});

Route::prefix("tag")->group(function () {
    Route::get("/", [BlogTagController::class, "list"]);
});

// blog comment rest api
Route::prefix("comment")->group(function () {
    Route::post("/", [BlogCommentController::class, "save"]);
});


Route::prefix("admin")->group(function () {
    // admin link rest api
    Route::prefix("link")->group(function () {
        Route::get("/", [AdminLinkController::class, "list_all"]);

        Route::post("/", [AdminLinkController::class, "save"]);

        Route::put("/{id}", [AdminLinkController::class, "update"]);

        Route::delete("/{id}", [AdminLinkController::class, "delete"]);
    });

    // admin category rest api
    Route::prefix("category")->group(function () {
        Route::get("/", [AdminCategoryController::class, "list"]);
        Route::post("/", [AdminCategoryController::class, "save"]);
        Route::put("/{id}", [AdminCategoryController::class, "update"]);
        Route::delete("/{id}", [AdminCategoryController::class, "delete"]);
    });

    // admin image upload rest api
    Route::prefix("image")->group(function () {
        Route::post("/", [AdminImageController::class, "save"]);
    });

    // admin config rest api
    Route::prefix("config")->group(function () {
        Route::get("/", [AdminConfigController::class, "list"]);
        Route::post("/", [AdminConfigController::class, "save"]);
        Route::put("/{id}", [AdminConfigController::class, "update"]);
        Route::delete("/{id}", [AdminConfigController::class, "delete"]);
    });

    // admin post rest api
    Route::prefix("post")->group(function () {
        Route::post("/", [AdminPostController::class, "save"]);
        Route::get("/", [AdminPostController::class, "listByPage"]);
        Route::get("/{id}", [AdminPostController::class, "findById"]);
        Route::delete("/{id}", [AdminPostController::class, "delete"]);
        Route::put("/{id}", [AdminPostController::class, "update"]);
    });

    // admin tag  rest api
    Route::prefix("tag")->group(function () {
        Route::get("/", [AdminTagController::class, "list"]);
        Route::post("/", [AdminTagController::class, "save"]);
        Route::put("/{id}", [AdminTagController::class, "update"]);
        Route::delete("/{id}", [AdminTagController::class, "delete"]);
    });

    Route::prefix("comment")->group(function () {
        Route::get("/", [AdminCommentController::class, "list"]);
        Route::delete("/{id}", [AdminCommentController::class, "delete"]);
        Route::put("/{id}", [AdminCommentController::class, "update"]);
    });

});

